//*************************************************************************
//  TIMER Funktionen des MEGA8
//
//  contact: sebastian.trommer@gmail.com
//  homepage: wiki.car2.de
//
//  Revision History
//
//  when         what  who	why
//
//  2009-02-23   0.01  TSE	initial release
//	2009-02-23	 0.02  TSE  Code reorganisiert aus altem Projekt
//
//**************************************************************************

#include <avr/io.h>

#include "ports.h"
#include "timer.h"

void TIMER_init() {
	// init Timer 1 im CTC mode
	TCCR1B |= (0<<WGM13)|(1<<WGM12)|(0<<WGM11)|(0<<WGM10);
	// Interrupt aktivieren
	TIMSK |= (1 << OCIE1A)|(1 << OCIE1B)|(1 << OCIE2);
	// Zaehlvariable
	OCR1A = CNT57K;
	// kein prescaler
	TCCR1B |= ((0 << CS12)|(0 << CS11)|(1 << CS10));
	// toggle OC1A
	TCCR1A |= (0<<COM1A1)|(1 << COM1A0);
}
